/*
* Copyright 2025 NXP
* NXP Proprietary. This software is owned or controlled by NXP and may only be used strictly in
* accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
* activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms.  If you do not agree to be bound by the applicable license
* terms, then you may not retain, install, activate or otherwise use the software.
*/

#include "lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
#include "events_init.h"
#include "widgets_init.h"
#include "custom.h"



void setup_scr_sleep(lv_ui *ui)
{
    //Write codes sleep
    ui->sleep = lv_obj_create(NULL);
    lv_obj_set_size(ui->sleep, 480, 480);
    lv_obj_set_scrollbar_mode(ui->sleep, LV_SCROLLBAR_MODE_OFF);

    //Write style for sleep, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_bg_opa(ui->sleep, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_image_src(ui->sleep, "S:/res/image/img_bg_health.bin", LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_image_opa(ui->sleep, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_image_recolor_opa(ui->sleep, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_title
    ui->sleep_title = lv_label_create(ui->sleep);
    lv_obj_set_pos(ui->sleep_title, 0, -61);
    lv_obj_set_size(ui->sleep_title, 480, 90);
    lv_obj_add_flag(ui->sleep_title, LV_OBJ_FLAG_FLOATING);
    lv_label_set_text(ui->sleep_title, "Sleep monitor");
    lv_label_set_long_mode(ui->sleep_title, LV_LABEL_LONG_WRAP);

    //Write style for sleep_title, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_border_width(ui->sleep_title, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_radius(ui->sleep_title, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_color(ui->sleep_title, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_font(ui->sleep_title, lv_font_montserratMedium_28_bin, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui->sleep_title, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_letter_space(ui->sleep_title, 1, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_line_space(ui->sleep_title, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_align(ui->sleep_title, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui->sleep_title, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(ui->sleep_title, 27, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_right(ui->sleep_title, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(ui->sleep_title, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_left(ui->sleep_title, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_image_src(ui->sleep_title, "S:/res/image/img_header_bg.bin", LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_image_opa(ui->sleep_title, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_image_recolor(ui->sleep_title, lv_color_hex(0xBD1C39), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_image_recolor_opa(ui->sleep_title, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_shadow_width(ui->sleep_title, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_cont_1
    ui->sleep_cont_1 = lv_obj_create(ui->sleep);
    lv_obj_set_pos(ui->sleep_cont_1, 132, 428);
    lv_obj_set_size(ui->sleep_cont_1, 206, 100);
    lv_obj_set_scrollbar_mode(ui->sleep_cont_1, LV_SCROLLBAR_MODE_OFF);
    lv_obj_add_flag(ui->sleep_cont_1, LV_OBJ_FLAG_FLOATING);

    //Write style for sleep_cont_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_border_width(ui->sleep_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_radius(ui->sleep_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui->sleep_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(ui->sleep_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(ui->sleep_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_left(ui->sleep_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_right(ui->sleep_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_shadow_width(ui->sleep_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_label_time
    ui->sleep_label_time = lv_label_create(ui->sleep_cont_1);
    lv_obj_set_pos(ui->sleep_label_time, 63, 42);
    lv_obj_set_size(ui->sleep_label_time, 97, 40);
    lv_label_set_text(ui->sleep_label_time, "17:25\n\n\n\n\n");
    lv_label_set_long_mode(ui->sleep_label_time, LV_LABEL_LONG_WRAP);

    //Write style for sleep_label_time, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_border_width(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_radius(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_color(ui->sleep_label_time, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_font(ui->sleep_label_time, lv_font_montserratMedium_35_bin, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui->sleep_label_time, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_letter_space(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_line_space(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_align(ui->sleep_label_time, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_right(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_left(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_shadow_width(ui->sleep_label_time, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_label_today
    ui->sleep_label_today = lv_label_create(ui->sleep_cont_1);
    lv_obj_set_pos(ui->sleep_label_today, 71, 17);
    lv_obj_set_size(ui->sleep_label_today, 83, 23);
    lv_label_set_text(ui->sleep_label_today, "TODAY");
    lv_label_set_long_mode(ui->sleep_label_today, LV_LABEL_LONG_WRAP);

    //Write style for sleep_label_today, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_border_width(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_radius(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_color(ui->sleep_label_today, lv_color_hex(0x757575), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_font(ui->sleep_label_today, lv_font_montserratMedium_18_bin, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui->sleep_label_today, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_letter_space(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_line_space(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_align(ui->sleep_label_today, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_right(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_left(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_shadow_width(ui->sleep_label_today, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_img_stages
    ui->sleep_img_stages = lv_image_create(ui->sleep);
    lv_obj_set_pos(ui->sleep_img_stages, 33, 146);
    lv_obj_set_size(ui->sleep_img_stages, 410, 164);
    lv_obj_add_flag(ui->sleep_img_stages, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_add_flag(ui->sleep_img_stages, LV_OBJ_FLAG_CLICKABLE);
    lv_image_set_src(ui->sleep_img_stages, "S:/res/image/img_chart_sleep.bin");
    lv_image_set_pivot(ui->sleep_img_stages, 50,50);
    lv_image_set_rotation(ui->sleep_img_stages, 0);

    //Write style for sleep_img_stages, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_image_recolor_opa(ui->sleep_img_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_image_opa(ui->sleep_img_stages, 255, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_label_stages
    ui->sleep_label_stages = lv_label_create(ui->sleep);
    lv_obj_set_pos(ui->sleep_label_stages, 135, 11);
    lv_obj_set_size(ui->sleep_label_stages, 204, 39);
    lv_label_set_text(ui->sleep_label_stages, "Sleep stages");
    lv_label_set_long_mode(ui->sleep_label_stages, LV_LABEL_LONG_WRAP);

    //Write style for sleep_label_stages, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_border_width(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_radius(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_color(ui->sleep_label_stages, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_font(ui->sleep_label_stages, lv_font_montserratMedium_28_bin, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui->sleep_label_stages, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_letter_space(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_line_space(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_align(ui->sleep_label_stages, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_right(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_left(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_shadow_width(ui->sleep_label_stages, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_img_1
    ui->sleep_img_1 = lv_image_create(ui->sleep);
    lv_obj_set_pos(ui->sleep_img_1, 401, 328);
    lv_obj_set_size(ui->sleep_img_1, 45, 61);
    lv_obj_add_flag(ui->sleep_img_1, LV_OBJ_FLAG_CLICKABLE);
    lv_image_set_src(ui->sleep_img_1, "S:/res/image/text_home.bin");
    lv_image_set_pivot(ui->sleep_img_1, 50,50);
    lv_image_set_rotation(ui->sleep_img_1, 0);

    //Write style for sleep_img_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_image_recolor_opa(ui->sleep_img_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_image_opa(ui->sleep_img_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_img_3
    ui->sleep_img_3 = lv_image_create(ui->sleep);
    lv_obj_set_pos(ui->sleep_img_3, 6, 220);
    lv_obj_set_size(ui->sleep_img_3, 12, 37);
    lv_obj_add_flag(ui->sleep_img_3, LV_OBJ_FLAG_FLOATING);
    lv_obj_add_flag(ui->sleep_img_3, LV_OBJ_FLAG_CLICKABLE);
    lv_image_set_src(ui->sleep_img_3, "S:/res/image/img_arrow_left.bin");
    lv_image_set_pivot(ui->sleep_img_3, 50,50);
    lv_image_set_rotation(ui->sleep_img_3, 0);

    //Write style for sleep_img_3, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_image_recolor_opa(ui->sleep_img_3, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_image_opa(ui->sleep_img_3, 255, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes sleep_img_2
    ui->sleep_img_2 = lv_image_create(ui->sleep);
    lv_obj_set_pos(ui->sleep_img_2, 460, 220);
    lv_obj_set_size(ui->sleep_img_2, 12, 37);
    lv_obj_add_flag(ui->sleep_img_2, LV_OBJ_FLAG_FLOATING);
    lv_obj_add_flag(ui->sleep_img_2, LV_OBJ_FLAG_CLICKABLE);
    lv_image_set_src(ui->sleep_img_2, "S:/res/image/img_arrow_right.bin");
    lv_image_set_pivot(ui->sleep_img_2, 50,50);
    lv_image_set_rotation(ui->sleep_img_2, 0);

    //Write style for sleep_img_2, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_image_recolor_opa(ui->sleep_img_2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_image_opa(ui->sleep_img_2, 255, LV_PART_MAIN|LV_STATE_DEFAULT);

    //The custom code of sleep.


    //Update current screen layout.
    lv_obj_update_layout(ui->sleep);

    //Init events for screen.
    events_init_sleep(ui);
}
